// // For more information about this file see https://dove.feathersjs.com/guides/cli/service.schemas.html
import { resolve } from '@feathersjs/schema'
import { Type, getValidator, querySyntax } from '@feathersjs/typebox'
import { dataValidator, queryValidator } from '../../validators.js'

// Main data model schema
export const baseInfoSchema = Type.Object(
  {
    id: Type.Number(),
    text: Type.String(),
    x: Type.String(),
    y: Type.String()
  },
  { $id: 'BaseInfo', additionalProperties: true }
)
export const baseInfoValidator = getValidator(baseInfoSchema, dataValidator)
export const baseInfoResolver = resolve({})

export const baseInfoExternalResolver = resolve({})

// Schema for creating new entries
export const baseInfoDataSchema = Type.Pick(baseInfoSchema, ['text'], {
  $id: 'BaseInfoData'
})
export const baseInfoDataValidator = getValidator(baseInfoDataSchema, dataValidator)
export const baseInfoDataResolver = resolve({})

// Schema for updating existing entries
export const baseInfoPatchSchema = Type.Partial(baseInfoSchema, {
  $id: 'BaseInfoPatch'
})
export const baseInfoPatchValidator = getValidator(baseInfoPatchSchema, dataValidator)
export const baseInfoPatchResolver = resolve({})

// Schema for allowed query properties
export const baseInfoQueryProperties = Type.Pick(baseInfoSchema, ['id', 'text'])
export const baseInfoQuerySchema = Type.Intersect(
  [
    querySyntax(baseInfoQueryProperties),
    // Add additional query properties here
    Type.Object({}, { additionalProperties: false })
  ],
  { additionalProperties: false }
)
export const baseInfoQueryValidator = getValidator(baseInfoQuerySchema, queryValidator)
export const baseInfoQueryResolver = resolve({})
